<template>
  <div class="weui-cell">
    <div class="weui-cell__bd">{{device.lable}}</div>
    <div class="weui-cell__ft">
      <switch checked @change="action" />
    </div>
  </div>
</template>

<script>
import { publishMessage } from "@/utils";
export default {
  name: "mpvue-button",
  data() {
    return {};
  },
  props: {
    device: Object
    // {
    //   type: "switch",
    //   lable: "LED",
    //   key: "LED",
    //   value: 1
    // },
  },
  mounted() {
    console.log(this.device);
  },
  methods: {
    action(e) {
      publishMessage(`{"${this.device.key}":${e.mp.detail.value ? 1 : 0}}`);
    }
  }
};
</script>

<style>
</style>
